

const db = require('../DB/index.js')

const sqlStr = 'select * from goodscount';
    db.query(sqlStr ,(err,results)=>{
        if(err) return console.log(err.message);
        /* console.log(results); */
        hjCount = {
            "message":{
                "count":results[0]
            },
        
            "meta":{
                "msg": "获取成功",
                "status": 200
            }
        
        },
        erjiCount = {
            "message":{
                "count":results[1]
            },
        
            "meta":{
                "msg": "获取成功",
                "status": 200
            }
        
        },
        jianpanCount = {
            "message":{
                "count":results[2]
            },
        
            "meta":{
                "msg": "获取成功",
                "status": 200
            }
        
        },
        shubiaoCount = {
            "message":{
                "count":results[3]
            },
        
            "meta":{
                "msg": "获取成功",
                "status": 200
            }
        
        },
        shoujiCount = {
            "message":{
                "count":results[4]
            },
        
            "meta":{
                "msg": "获取成功",
                "status": 200
            }
        
        }
    })

exports.goodsCount = (req,res)=>{
    
    


    if(req.query.goods_id==101){
        res.send(hjCount) 
    }
    if(req.query.goods_id==102){
        res.send(erjiCount)
    }
    if(req.query.goods_id==103 || req.query.goods_id==129){
        res.send(jianpanCount)
    }
    if(req.query.goods_id==104){
        res.send(shubiaoCount)
    }
    if(req.query.goods_id==57000){
        res.send(shoujiCount)
    }



}